import { TabType } from '/@/components/chinaMap/chinaHooks.ts';
import { getMapListApi } from '/@/views/centralScreen/centralScreen.api.ts';

export const legend1 = new URL('/@/assets/img/legend1.png', import.meta.url).href;
export const legend2 = new URL('/@/assets/img/legend2.png', import.meta.url).href;
export const legend3 = new URL('/@/assets/img/legend3.png', import.meta.url).href;
export const legend4 = new URL('/@/assets/img/legend4.png', import.meta.url).href;
export const legend5 = new URL('/@/assets/img/legend5.png', import.meta.url).href;
export const legend7 = new URL('/@/assets/img/legend7.png', import.meta.url).href;
export const legendList = [
    { img: legend1, text: '油田医院' },
    { img: legend2, text: '医疗点' },
    { img: legend7, text: '关联医疗点' },
    { img: legend3, text: '救护车' },
    { img: legend4, text: '合作医院' },
    { img: legend5, text: '地方医院' },
];

export function mapApiSwitch(type: string, params: any) {
    const basicParams = {
        lat: 34, //纬度34
        lon: 108, //经度
    };
    // 全部  医疗点
    if ([TabType.all, TabType.yiLiaoDian].includes(type)) {
        return getMapListApi({ ...basicParams, ...params });
    }
    // 其他
    if ([TabType.youTianYiYuan, TabType.heZuoYiYuan, TabType.jiuHuChe, TabType.jiuHuChe].includes(type)) {
        let { centerId, ...other } = params;
        return getMapListApi({ ...basicParams, ...other });
    }
}

export function handleSocketUrl(url: string, centerId: string) {
    return url.substring(0, url.indexOf('/websocket/') + 11) + centerId;
}
